'''
加了 slots 之后，class 就没有 __dict__ 属性了
也无法添加 slots 之外的类变量
类变量不能和 slots 里面的变量同名
'''


class SlotObject():
    __slots__ = ('x')
    v = 8
    # x = 10  # ValueError: 'x' in __slots__ conflicts with class variable

    def __init__(self):
        pass


s = SlotObject()
# print(s.__dict__)  # AttributeError: 'SlotObject' object has no attribute '__dict__'

s.x = 200
print(s.x)
# s.y = 200  # AttributeError: 'SlotObject' object has no attribute 'y'
